#include "PureString.h"
#include "CppUnitLite/TestHarness.h"
#include "stdio.h"
SimpleString StringFrom(const Pure::String& value)
{
    return SimpleString(value.utf8());
}



TEST(PureString, creation)
{
    Pure::String s("Hello World!");
    CHECK_EQUAL(s, "Hello World!");
    Pure::String s1;
    POINTERS_EQUAL(NULL, s1.utf8());
    Pure::String s2(10);
    LONGS_EQUAL(10, s2.length());
    Pure::String s3(s);
    CHECK_EQUAL(s, s3);
}

TEST(PureString, append)
{
    Pure::String s;
    s.append("Hello World!");
    CHECK_EQUAL("Hello World!", s);
    s.append("");
    CHECK_EQUAL("Hello World!", s);
    s.append((const char*)NULL);
    CHECK_EQUAL("Hello World!", s);
}

TEST(PureString, operatorAppend)
{
    Pure::String s;
    s += "Hello";
    CHECK_EQUAL("Hello", s);
    s += "";
    CHECK_EQUAL("Hello", s);
    s += (const char*)NULL;
    CHECK_EQUAL("Hello", s);
    Pure::String s2(" World!");
    s += s2;
    CHECK_EQUAL("Hello World!", s);
    s2.clear(true);
    s += s2;
    CHECK_EQUAL("Hello World!", s);
}

TEST(PureString, clear)
{
    Pure::String s("Hello World!");
    s.clear();
    LONGS_EQUAL(0, s.length());
    CHECK_EQUAL("", s);
    Pure::String s1("Hello World!");
    s1.clear(true);
    LONGS_EQUAL(0, s1.length());
    POINTERS_EQUAL(NULL, s1.utf8());
}